package com.springboot.staticcode.converter;


import com.springboot.domain.User;
import com.springboot.mvc.vo.UserVO;
import com.springboot.store.po.UserPO;
import com.springboot.store.system.to.UserTO;

/**
 * <p>领域对象User转换器</p>
 *
 * @author  yangz
 * @date    2015/9/10
 * @version latest
 */
public class UserBeanConverter implements IBeanConverter<User, UserPO, UserVO, UserTO>{

    @Override
    public User v2d(UserVO vo) {
        User result = new User();
        result.setId(vo.getId());
        result.setUsername(vo.getUsername());
        result.setPassword(vo.getPassword());
        result.setNickname(vo.getNickname());
        return result;
    }

    @Override
    public UserPO d2p(User domain) {
        UserPO result = new UserPO();
        result.setId(domain.getId());
        result.setUsername(domain.getUsername());
        result.setPassword(domain.getPassword());
        result.setNickname(domain.getNickname());
        return result;
    }

    @Override
    public User p2d(UserPO po) {
        User result = new User();
        result.setId(po.getId());
        result.setUsername(po.getUsername());
        result.setPassword(po.getPassword());
        result.setNickname(po.getNickname());
        return result;
    }

    @Override
    public UserVO d2v(User domain) {
        UserVO result = new UserVO();
        result.setId(domain.getId());
        result.setUsername(domain.getUsername());
        result.setPassword(domain.getPassword());
        result.setNickname(domain.getNickname());
        return result;
    }

    @Override
    public UserTO d2t(User domain) {
        UserTO result = new UserTO();
        result.setId(domain.getId());
        result.setUsername(domain.getUsername());
        result.setPassword(domain.getPassword());
        result.setNickname(domain.getNickname());
        return result;
    }

    @Override
    public User t2d(UserTO to) {
        User result = new User();
        result.setId(to.getId());
        result.setUsername(to.getUsername());
        result.setPassword(to.getPassword());
        result.setNickname(to.getNickname());
        return result;
    }
}
